#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char str[1000];
    int key, i;
    while (scanf("%s%d", str, &key) == 2)
    {
        key %= 26;
        for (i = 0; str[i] != '\0'; i++)
        {
            str[i] -= key + (i + 1) % 26;
            while (str[i] < 'A')
                str[i] += 26;
        }
        puts(str);
    }
    return 0;
}
